import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(),
  // 配置映射关系：path => component
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: () => import('../views/home/index.vue')
    },
    {
      path: '/hospital',
      name: 'hospital',

      component: () => import('../views/hospital/index.vue'),
      children: [
        {
          path: 'register',
          component: () => import('../views/hospital/register/index.vue'),
          meta: {
            title: '预约挂号'
          },
          name: 'register',
          children: [
            {
              path: 'step1',
              component: () =>
                import('../views/hospital/register/register_step1.vue'),
              meta: {
                title: '挂号',
                name: 'step1'
              }
            },
            {
              path: 'step2',
              component: () =>
                import('../views/hospital/register/register_step2.vue'),
              meta: {
                title: '确认挂号信息',
                name: 'step2'
              }
            }
          ]
        },

        {
          path: 'detail',
          name: 'detail',
          component: () => import('../views/hospital/detail/index.vue'),
          meta: {
            title: '医院详情'
          }
        },
        {
          path: 'notice',
          name: 'notice',
          component: () => import('../views/hospital/notice/index.vue'),
          meta: {
            title: '预约须知'
          }
        },
        {
          path: 'close',
          name: 'close',
          component: () => import('../views/hospital/close/index.vue'),
          meta: {
            title: '停诊信息'
          }
        },
        {
          path: 'search',
          name: 'search',
          component: () => import('../views/hospital/searchOrcancel/index.vue'),
          meta: {
            title: '查询/取消'
          }
        }
      ]
    },
    {
      path: '/user',
      name: 'user',
      component: () => import('../views/user/index.vue'),
      children: [
        {
          path: 'certification',
          component: () => import('../views/user/certification/index.vue'),
          meta: {
            title: '实名认证'
          },
          name: 'certification'
        },
        {
          path: 'order',
          name: 'order',
          component: () => import('../views/user/order/index.vue'),
          meta: {
            title: '挂号订单'
          }
        },
        {
          path: 'patient',
          component: () => import('../views/user/patient/index.vue'),
          meta: {
            title: '就诊人管理'
          },
          name: 'patient'
        },
        {
          path: 'profile',
          name: 'profile',
          component: () => import('../views/user/profile/index.vue'),
          meta: {
            title: '帐号信息'
          }
        },
        {
          path: 'feedback',
          name: 'feedback',
          component: () => import('../views/user/feedback/index.vue'),
          meta: {
            title: '意见反馈'
          }
        }
      ]
    },
    {
      path: '/:pathMatch(.*)',
      component: () => import('../views/not-found/index.vue')
    }
  ]
})

export default router
